from django.contrib import admin
from location.models import State, City, Suburb, Street

__author__ = 'leroy'

class StateAdmin(admin.ModelAdmin):
    list_display = ('name', 'abbreviation',)
    list_display_links = ('name',)
    ordering = ['name']
    search_fields = ['name', 'abbreviation']
    prepopulated_fields = {'slug' : ('name',), 'tags':('name', 'abbreviation',)}
admin.site.register(State, StateAdmin)

class CityAdmin(admin.ModelAdmin):
    list_display = ('name', 'abbreviation','state',)
    list_display_links = ('name',)
    ordering = ['state','name',]
    search_fields = ['name', 'abbreviation']
    prepopulated_fields = {'slug':('name',), 'tags':('name', 'abbreviation',)}
admin.site.register(City, CityAdmin)

class SuburbAdmin(admin.ModelAdmin):
    list_display = ('name', 'postcode', 'city',)
    list_display_links = ('name',)
    ordering = ['-postcode', 'name']
    search_fields = ['name', 'postcode']
    prepopulated_fields = {'slug' : ('name',), 'tags':('name',)}
admin.site.register(Suburb, SuburbAdmin)

class StreetAdmin(admin.ModelAdmin):
    list_display = ('name', 'suburb')
    list_display_links = ('name',)
    ordering = ['-suburb', 'name',]
    search_fields = ['name']
    prepopulated_fields = {'slug' : ('name',), 'tags':('name',)}
admin.site.register(Street, StreetAdmin)

